﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="InvoiceList.aspx.cs" Inherits="TireService.Web.Finance.InvoiceList" %>

<%@ Register assembly="DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v10.2.Export, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script src="../Scripts/ModalPopup.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">

        function confirm_submit(elem) {
            if (elem != null) {
                var myValue = elem.options[elem.selectedIndex].value;
                var myText = elem.options[elem.selectedIndex].text;

                if (myValue == 4 | myValue == 5)
                    if (myValue == 4 | myValue == 5) {
                        if (confirm("Ønsker du at angive valgte fakturaer som betalte?"))
                            return true;
                        else {
                            return false;
                        }
                    }
                    else {
                        return true;
                    }
            }
        }
        
    
    </script>
    
    <dx:ASPxRoundPanel ID="rpContent" runat="server" Width="100%" ShowHeader="true" Height="100%">
        <PanelCollection>
            <dx:PanelContent ID="PanelContent1" runat="server">
                
                <asp:UpdatePanel ID="upMessage" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <table border="0" cellspacing="0" cellpadding="5">
                            <tr>
                                <td>
                                    <div style="font-family: Tahoma; font-size: 9pt; font-weight: normal; color: #f15e34">
                                        &nbsp;<asp:Literal ID="lMessage" runat="server"></asp:Literal>
                                    </div>
                                </td>
                            </tr>
                        </table>          
                    </ContentTemplate>
                </asp:UpdatePanel>
                
                <asp:UpdatePanel ID="upInvoiceAction" runat="server">
                    <ContentTemplate>
                        <table border="0" cellspacing="0" cellpadding="5" width="100%">
                            <tr>
                                <td>
                                    <asp:DropDownList ID="ddlAction" runat="server">
                                        <asp:ListItem Selected="True" Value="0">-- Handling --</asp:ListItem>
                                        <asp:ListItem Value="1">Rediger valgte</asp:ListItem>
                                        <asp:ListItem Value="4">Marker som betalt og send email</asp:ListItem>
                                        <asp:ListItem Value="5">Marker som betalt</asp:ListItem>
                                        <asp:ListItem Value="6">Email faktura til valgte</asp:ListItem>
                                        <asp:ListItem Value="7">Email betalingspåmindelse til valgte</asp:ListItem>
                                    </asp:DropDownList>
                                    &nbsp;
                                    <asp:Button ID="btnSubmitAction" runat="server" Text="Udfør" 
                                        onclick="btnSubmitAction_Click" />
                                    &nbsp;
                                    <asp:DropDownList ID="ddlExport" runat="server">
                                        <asp:ListItem Selected="True" Value="0">Export pdf</asp:ListItem>
                                        <asp:ListItem Value="1">Export xls</asp:ListItem>
                                        <asp:ListItem Value="2">Export csv</asp:ListItem>
                                        <asp:ListItem Value="3">Export rtf</asp:ListItem>
                                    </asp:DropDownList>
                                    &nbsp;
                                    <asp:Button ID="btnExport" runat="server" CausesValidation="False" 
                                        Text="Exporter" onclick="btnExport_Click" />
                                </td>
                                <td align="right">
                                    <asp:Label ID="lblFilter" runat="server" Text="Filter"></asp:Label>
                                    <asp:DropDownList ID="ddlFilter" runat="server" AutoPostBack="True" AppendDataBoundItems="true">
                                    </asp:DropDownList>
                                    &nbsp;
                                    <asp:Label ID="lblPageSize" runat="server" Text="Antal linjer pr side"></asp:Label>
                                    <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true">
                                        <asp:ListItem Value="10">10</asp:ListItem>
                                        <asp:ListItem Value="25">25</asp:ListItem>
                                        <asp:ListItem Value="50">50</asp:ListItem>
                                        <asp:ListItem Value="100">100</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>          
                    </ContentTemplate>    
                </asp:UpdatePanel>
                
                <asp:UpdatePanel ID="upInvoice" runat="server">
                    <ContentTemplate>
                        <dxwgv:ASPxGridView ID="gvInvoice" runat="server" ClientInstanceName="gvInvoice" KeyFieldName="InvoiceId"
                            Width="100%" AutoGenerateColumns="False" EnableCallBacks="False"
                            onrowdeleting="gvInvoice_RowDeleting"
                            oncustomunboundcolumndata="gvInvoice_CustomUnboundColumnData" 
                            oncustombuttoncallback="gvInvoice_CustomButtonCallback">
                            <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                            <Settings ShowPreview="false" ShowHeaderFilterButton="true" ShowGroupPanel="true" ShowFilterRow="True" />
                            <SettingsPager AlwaysShowPager="True" PageSize="20" Position="TopAndBottom">
                                <Summary 
                                    AllPagesText="Sider: {0} - {1} ({2} fakturaer)" 
                                    Text="Side {0} af {1} ({2} fakturaer)" />
                            </SettingsPager>
                            <SettingsText ConfirmDelete="Vil du slette denne faktura?" GroupPanel="Træk kolonne hertil for at gruppere efter den" HeaderFilterShowAll="Vis alle" />
                            <SettingsBehavior ConfirmDelete="True" AllowGroup="true" AllowDragDrop="true" />
                            
                            <Columns>
                                <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                                     <HeaderTemplate>
                                         <input type="checkbox" onclick="gvInvoice.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                                     </HeaderTemplate>
                                     <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                         HorizontalAlign="Center">
                                        <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                                     </HeaderStyle>
                                </dxwgv:GridViewCommandColumn>
                                <dxwgv:GridViewCommandColumn VisibleIndex="1">
                                    <DeleteButton Text="Slet" Visible="True">
                                    </DeleteButton>
                                    <CustomButtons>
                                        <dxwgv:GridViewCommandColumnCustomButton Text="Rediger" ID="Edit" />
                                    </CustomButtons>
                                </dxwgv:GridViewCommandColumn>
                                <dxwgv:GridViewDataHyperLinkColumn FieldName="InvoiceGuid" VisibleIndex="2" Caption="Vis">
                                    <PropertiesHyperLinkEdit NavigateUrlFormatString="http://www.mobilhjulskift.dk/Reports/View/Faktura.aspx?InvoiceGuid={0}" TextField="InvoiceId" Target="_blank">
                                    </PropertiesHyperLinkEdit>
                                </dxwgv:GridViewDataHyperLinkColumn>
                                <dxwgv:GridViewDataColumn FieldName="InvoiceId" Visible="true" VisibleIndex="3" Caption="Nr">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataTextColumn FieldName="InvoiceDate" VisibleIndex="3" Caption="Fakturadato">
                                </dxwgv:GridViewDataTextColumn>
                                <dxwgv:GridViewDataTextColumn FieldName="DueDate" VisibleIndex="3" Caption="Forfaldsdato">
                                </dxwgv:GridViewDataTextColumn>
                                <dxwgv:GridViewDataTextColumn FieldName="CustomerId" VisibleIndex="4" Caption="Kundenr">
                                </dxwgv:GridViewDataTextColumn>
                                <dxwgv:GridViewDataColumn FieldName="InvoiceStatusId" VisibleIndex="8" Caption="InvoiceStatusId" Visible="false">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="InvoiceGuid" VisibleIndex="8" Caption="InvoiceGuid" Visible="false">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataTextColumn FieldName="InvoiceStatusDescription" VisibleIndex="9" UnboundType="String" Caption="Status">
                                </dxwgv:GridViewDataTextColumn>
                            </Columns>                
                        </dxwgv:ASPxGridView>
                    </ContentTemplate>
                </asp:UpdatePanel>
                
                
                <dxwgv:ASPxGridViewExporter ID="gvExport" runat="server" GridViewID="gvInvoice">
                </dxwgv:ASPxGridViewExporter>
                
            </dx:PanelContent>
        </PanelCollection>
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="2" border="0">
                <tr>
                    <td>
                        <img id="imgInvoice" alt="" src="~/Images/Medium/cashier.png" runat="server" style="width: 32px; height: 32px" />
                    </td>
                    <td valign="middle">
                        <h3><asp:Label ID="lblInvoiceHeader" runat="server" Text="Faktura"></asp:Label></h3>
                    </td>
                </tr>
            </table>
        </HeaderTemplate>
    </dx:ASPxRoundPanel>

</asp:Content>
